package com.ilancuo.reference;

import java.lang.ref.WeakReference;

/**
 * 弱引用
 *
 * Created by ilancuo on 2017/1/9.
 */
public class WeakReferenceTest {

    public static void main(String... args) {
        String s = new String("abc");
        WeakReference<String> wReference = new WeakReference<>(s);
        s = null;
        System.out.println("before gc: " + wReference.get());
        System.gc();
        System.out.println("after gc: " + wReference.get());
    }
}
